﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WLMCoreLibrary;
using MiWebSite_Core;
using System.Xml;

namespace MWS_AddDirectory.RegTwitter
{
    public partial class Default : System.Web.UI.Page
    {


        protected void Page_Load(object sender, EventArgs e)
        {
            //WebSiteMainConfiguration config = WebSiteMainConfiguration.GetConfig();
            //List<ParametroTransformacionXML> parametros = new List<ParametroTransformacionXML>();
            //if (Request.QueryString["xml"] != null)
            //{
            dbConnector ConexionDB = new dbConnector();
            //    MiWebSitePage pagina = new MiWebSitePage(conexion);
            //    pagina.DomainName = CurrentDomain.DomainName;
            //    if (CurrentUser.IdUsuario != 0)
            //    {
            if (Request["oauth_token"] == null)
            {
                Twitter tw = new Twitter();
                string redireccion = tw.RequestAuthorization(new MiWebSiteDomain(DeCurrentDomain.IdentificadorDominio, ref ConexionDB));
                Response.Redirect(redireccion);
            }
            else
            {
                XmlDocument xmlModulos = new XmlDocument();
                //pagina.Contenido = xmlModulos.CreateElement("Portada");
                Twitter tw = new Twitter();
                tw.AutorizarTwit(Request["oauth_token"], Request["oauth_verifier"], new MiWebSiteDomain(DeCurrentDomain.IdentificadorDominio, ref ConexionDB));

            }

            //    }
            ConexionDB.CloseConnection();
            //    CurrentDomain.Refresh();
            //}
            //else
            //{
            //    string HTMLPagina = WLMFunctions.TransformXML(config.Settings["siteURL"].value + "?xml=true", config.Settings["siteURL"].value + config.Settings["skinPath"].value + "index.xsl", parametros);
            //    Response.Write(HTMLPagina);
            //}
        }
    }
}